package com.gitee.faster.webdav.kernel.protocol.dispatcher;

import cn.hutool.core.collection.CollUtil;
import com.gitee.faster.webdav.common.constant.MethodEnum;
import com.gitee.faster.webdav.kernel.model.Prop;
import com.gitee.faster.webdav.kernel.model.PropPatch;
import com.gitee.faster.webdav.kernel.model.Set;
import com.gitee.faster.webdav.kernel.protocol.HttpExchange;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @author hongda.li
 */
@Slf4j
public class MethodDispatcherPropPatch implements MethodDispatcher {
    @Override
    public MethodEnum supported() {
        return MethodEnum.PROPPATCH;
    }

    @Override
    public void dispatch(HttpExchange httpExchange) {
        PropPatch patch = httpExchange.parseXmlData(PropPatch.class);

        List<Set> setList = patch.filterSetList();
        if (CollUtil.isNotEmpty(setList)) {
            log.info("更新属性 : {}", setList);
            setList.forEach(set -> {
                Prop prop = set.getProp();
               // prop.getDisplayName()
            });
        }

        log.info("移除属性 : {}", patch.filterRemoveList());
    }
}
